package juegos.ui.views;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.event.EventListenerList;

import juegos.ui.generados.PantallaPrincipal;
import juegos.utlidades.ImageCache;

@SuppressWarnings("serial")
public class PanelReglas extends JPanel {

	private BufferedImage background;
	private JButton next;
	private EventListenerList eventListenerList = new EventListenerList();
	static PantallaPrincipal panelInicial;

	public PanelReglas() {
		setLayout(null);
		cargarComponentes();
	}

	private void cargarComponentes() {
		background = ImageCache.getInstance().getImage(
				"src/juegos/ui/imagenes/Pantalla3.jpg");
		next = new JButton("Siguiente>>");
		next.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				fireActionEvent(new ActionEvent(this, 0, "PanelEncuentraDiferencias"));
			}
		});
		
		next.setBounds(380, 600, 130, 30);
		next.setFont(new Font("Serf", Font.BOLD, 16));
		next.setForeground(Color.WHITE);
		next.setBackground(Color.DARK_GRAY);
		add(next);
	}

	public void addActionListener(ActionListener listener) {
		eventListenerList.add(ActionListener.class, listener);
	}

	public void removeActionListener(ActionListener listener) {
		eventListenerList.remove(ActionListener.class, listener);
	}

	public ActionListener[] getActionListeners() {
		return eventListenerList.getListeners(ActionListener.class);
	}

	private void fireActionEvent(ActionEvent evt) {
		ActionListener[] actionListeners = getActionListeners();

		for (ActionListener actionListener : actionListeners) {
			actionListener.actionPerformed(evt);
		}
	}

	@Override
	public void paintComponent(Graphics g) {
		g.drawImage(background, 0, 0, background.getWidth(),
				background.getHeight(), null);
	}
}
